<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1"><link rel="icon" href="./logo.ico"><title>思绪思维导图</title><script>// 自定义静态资源的路径
      window.externalPublicPath = './'
      // 接管应用
      window.takeOverApp = true</script><link href="css/chunk-vendors.css?6cb8c2514dee6bd5d93c" rel="stylesheet"><link href="css/app.css?6cb8c2514dee6bd5d93c" rel="stylesheet"></head><body><noscript><strong>We're sorry but thoughts doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script>const getDataFromBackend = () => {
        return new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve({
              mindMapData: {
                root:{
                  "data": {
                      "text": "根节点"
                  },
                  "children": []
                },
                theme:{
                  "template":"classic4",
                  "config":{}
                },
                layout:"mindMap",
                config: {},
                view: null,
              },
              lang: 'zh',
              localConfig: null
            })
          }, 200)
        })
      }
      const setTakeOverAppMethods = data => {
        window.takeOverAppMethods = {}
        // 获取思维导图数据的函数
        window.takeOverAppMethods.getMindMapData = () => {
          if (window.mindMap) {
            return window.mindMap.getData(true)
          }
          return data.mindMapData
        }
        // 保存思维导图数据的函数
        window.takeOverAppMethods.saveMindMapData = data => {
          window.localStorage.setItem('mindMapData', JSON.stringify(data))
        }
        // 获取语言的函数
        window.takeOverAppMethods.getLanguage = () => {
          return data.lang
        }
        // 保存语言的函数
        window.takeOverAppMethods.saveLanguage = lang => {
          console.log(lang)
        }
        // 获取本地配置的函数
        window.takeOverAppMethods.getLocalConfig = () => {
          return data.localConfig
        }
        // 保存本地配置的函数
        window.takeOverAppMethods.saveLocalConfig = config => {
          console.log(config)
        }
        window.takeOverAppMethods.sendData = result => {
          window.top.postMessage(
            {
              type: 'sendData',
              data: result
            },
            '*'
          )
        }
        window.takeOverAppMethods.getDownLoadFileResult = result => {
          window.top.postMessage(
            {
              type: 'downloadFileResult',
              indent: 'top',
              data: result
            },
            '*'
          )
        }
      }
      window.onload = async () => {
        if (!window.takeOverApp) return
        // 请求数据
        let data = null
        if (window.localStorage.getItem('mindMapData')) {
          try {
            data = {
              mindMapData: JSON.parse(
                window.localStorage.getItem('mindMapData')
              ),
              lang: 'zh',
              localConfig: null
            }
          } catch (error) {
            data = await getDataFromBackend()
          }
        } else {
          data = await getDataFromBackend()
        }
        // 设置全局的方法
        setTakeOverAppMethods(data)
        // 思维导图实例创建完成事件
        window.$bus.$on('app_inited', mindMap => {
          // console.log(mindMap)
          window.mindMap = mindMap

          window.addEventListener('message', ({ data }) => {
            let { message } = data

            if(message == 'mindmap'){
              let callFunc = (data.callFunc || '').split('.').filter(funcName => funcName != '')
              let callback = callFunc.reduce((callObj, funcName) => ((funcObj, parent) => {
                return typeof funcObj === 'function' ? funcObj.bind(parent) : funcObj
              })(callObj[funcName], callObj), mindMap)
              return callback(...(data.args || []))
            }
          })
        })
        // 可以通过window.$bus.$on()来监听应用的一些事件
        // 实例化页面
        window.initApp()
      }</script><script src="js/chunk-vendors.js?6cb8c2514dee6bd5d93c"></script><script src="js/app.js?6cb8c2514dee6bd5d93c"></script></body></html>